#ifndef MYPAINTER_H
#define MYPAINTER_H

#include <QMainWindow>
#include <QPaintEvent>
#include <QPainter>
#include <QMouseEvent>
#include <QPen>
#include <QPoint>
#include <QLine>
#include <QVector>
#include <QColorDialog>
#include <QInputDialog>


QT_BEGIN_NAMESPACE
namespace Ui { class MyPainter; }
QT_END_NAMESPACE

typedef struct ColorLines
{
    QLine* line;        //线段：
    QColor color;      //颜色
    int width;              //宽度

}ColorLines;


class MyPainter : public QMainWindow
{
    Q_OBJECT

public:
    MyPainter(QWidget *parent = nullptr);
    ~MyPainter();

private:
    Ui::MyPainter *ui;

private:
    QColor penColor;                //画笔的颜色
    int penWidth;                       //画笔的宽度
    bool isPressed;                  //是否按下
    QPoint startPoint;              //开始点
    QPoint endPoint;                //结束点
    QVector<ColorLines*> lines;       //所有的线段

public:
    void paintEvent(QPaintEvent* ev);                          //绘图事件

    void mousePressEvent(QMouseEvent* ev);                  //鼠标按下事件
    void mouseMoveEvent(QMouseEvent* ev);                   //鼠标移动事件
    void mouseReleaseEvent(QMouseEvent* ev);             //鼠标抬起事件


public slots:
    void onColorDlgSlot();                                                      //弹出颜色选择对话框
    void onWidthDlgSlot();                                                      //演出输入宽度

};
#endif // MYPAINTER_H
